// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OrderTrackingEventArgs.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.Forge.Events
{
    #region Usings

    using System;

    using Org.OpenTrader.Framework.Events;
    using Org.OpenTrader.Framework.Forge.Interfaces;

    #endregion

    /// <summary>
    /// The order tracking event args.
    /// </summary>
    [Serializable]
    public abstract class OrderTrackingEventArgs : DispatchableEventArgs
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="OrderTrackingEventArgs"/> class.
        /// </summary>
        /// <param name="orderId">
        /// The orderId.
        /// </param>
        /// <param name="cell">
        /// The cell.
        /// </param>
        public OrderTrackingEventArgs(Guid orderId, IOrderTrackingCell cell)
            : base(orderId)
        {
            this.OrderTrackingCell = cell;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets YCell.
        /// </summary>
        public IOrderTrackingCell OrderTrackingCell { get; private set; }

        #endregion

        /// <summary>
        /// The asynchronous update.
        /// </summary>
        [Serializable]
        public class AsynchronousUpdate : OrderTrackingEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="AsynchronousUpdate"/> class. 
            /// </summary>
            /// <param name="orderId">
            /// The orderId.
            /// </param>
            /// <param name="cell">
            /// The cell.
            /// </param>
            /// <param name="relatedOrderEventArgs">
            /// The related Order Event ForwardToSubscriberArgs.
            /// </param>
            public AsynchronousUpdate(Guid orderId, IOrderTrackingCell cell, OrderEventArgs relatedOrderEventArgs)
                : base(orderId, cell)
            {
                this.RelatedOrderEventArgs = relatedOrderEventArgs;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets the OrderEventArgs related to this event, as this event was produced on asynchronous order event reception in the tracker
            /// </summary>
            public OrderEventArgs RelatedOrderEventArgs { get; private set; }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("AsynchronousUpdate[OrderID={0},RelatedZZZ.OrderEventArgs={1}]", this.ObjectID, this.RelatedOrderEventArgs.ToString());
            }

            #endregion
        }

        /// <summary>
        /// The synchronous update.
        /// </summary>
        [Serializable]
        public class SynchronousUpdate : OrderTrackingEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="SynchronousUpdate"/> class. 
            /// </summary>
            /// <param name="orderId">
            /// The orderId.
            /// </param>
            /// <param name="cell">
            /// The cell.
            /// </param>
            public SynchronousUpdate(Guid orderId, IOrderTrackingCell cell)
                : base(orderId, cell)
            {
            }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("SynchronousUpdate[OrderID={0}]", this.ObjectID);
            }

            #endregion
        }
    }
}